SetAxisCam
連結軸並開始凸輪運動。
語法
KsCommandStatus SetAxisCam(
int Master,
int Slave,
BOOL Permanent,
double MasterOffset,
double SlaveOffset,
double MasterScaling,
double SlaveScaling,
McCamStartMode StartMode,
double StartParameter,
McSource MasterValueSource,
int Cam,
McBufferMode BufferMode
);
參數
Master [in]:主軸索引。索引以零為起點;別名將影響此參數。
Slave [in]:從軸索引。索引以零為起點;別名將影響此參數。從軸之最大數量為 32 軸。
Permanent [in]:決定馬達停用後是否保留凸輪狀態。
TRUE:馬達停用但保留凸輪狀態,例如當主軸啟用時從軸也會跟著啟用,而當主軸發生錯誤從軸也會發生錯誤。
FALSE:馬達停用後不會保留凸輪狀態。
MasterOffset [in]:凸輪表中主軸位置的偏移量。
SlaveOffset [in]:凸輪表中從軸位置的偏移量。
MasterScaling [in]:主設定檔因子(預設值 = 1.0),以從軸的角度來看,該因子乘以整個主設定檔。
SlaveScaling [in]:從設定檔因子(預設值 = 1.0),該因子乘以整個從設定檔。
StartMode [in]:從軸所用的凸輪模式。請見 McCamStartMode 類型
StartParameter [in]:依選擇的斜坡而定,若為 camRampDistance
,StartParameter 即為從軸移動的距離,單位為計數;若為 camRampTime
,StartParameter 即為從軸移動的時間,每秒為一單位。該參數使用主軸的資訊來決定如何移動從軸,而距離取決於主軸移動的距離。
MasterValueSource [in]:定義同步的來源。請見 McSource 類型
- mcSetValue – 同步主軸設定值,建議使用此設定。
- mcActualValue-同步主軸實際值,此設定可能不穩定。
- mcSecondEncoderValue – 軸的第二編碼器實際值。
注意:尚未支援 mcSecondEncoderValue。
Cam [in]:凸輪表的索引,連接到 SetCamTable 的輸出。 .
BufferMode [in]:定義如何融合兩功能的速度,請見 McBufferMode 類型
回傳值
返回 KsCommandStatus 結構。
備註
- 此功能不與 SetCamTable 合併,因為這種分離可即時更改。
- 從軸偏移的機械類比是凸輪與額外的恆定層厚度焊接,如此從位置具有恆定的偏移量,若採用直線導向從動件,則該偏移量可表示主軸的軸偏移量。
- 欲分離從軸,請使用 ReleaseAxis。
- 當模數軸啟用時,SetAxisCam 將不受影響,該軸不會將凸輪表中的位置視為模數位置。例如,假設主軸與從軸同步運行,且兩者的模數值皆設定為 360。在凸輪表中,下一個 MasterPosition 和 SlavePosition 分別設定為 360 和 540。在此情況下,主軸將旋轉 1 圈,而從軸將旋轉 1.5 圈,以達到設定的位置。啟用模數軸後,建議使用者:
- 使用 SetAxisPositionOffset 重設位置,以防止顯示位置與內部位置不一致。例如,當模數值設為 360 時,使用者可能會看到位置為 0,而內部位置為 360000。
- 使用速度或距離 API 來移動主軸。
範例
KsCommandStatus AssignCamSlave(INT Master, INT Slave, INT Table) {
BOOL InSync = FALSE;
BOOL Busy = FALSE;
BOOL Active = FALSE;
BOOL CommandAborted = FALSE;
BOOL Error = FALSE;
WORD ErrorId = 0;
INT QueueIndex = -1;
BOOL EndOfProfile = FALSE;
KsCommandStatus cam = SetAxisCam(Master, Slave, FALSE,
0, //Master Offset. Offset to add to the master positions in the CAM table
0, //Slave Offset. Offset to add to the slave positions in the CAM table
1, /*Master Scaling. Ratio to apply to the distance between
the master positions and the original position*/
1, //Slave Scaling. Ratio to apply to the slave positions in the CAM table
camRelative, //StartMode.
/*Absolute: The slave axis will jump to its target in the table.
Alarms may be triggered if the position is too far.*/
//Relative: The current master/slave positions are used as origin for the CAM table.
/*Ramp Distance: The slave axis will ramp to its target position
while the master axis moves along the distance provided in StartParameter*/
/*Ramp Time: The slave axis will ramp to its target position
over the period of time provided in seconds in StartParameter*/
0, //Start Parameter
mcSetValue, /*Master Value Source. Value of the master position used.
Cam be the target position (commanded value and set value are identical)
or the actual position.*/
Table,
mcAborting
);
return cam;
}
使用需求
RT | Win32 | |
---|---|---|
最低支援版本 | 4.0 | 4.0 |
標頭檔 | ksmotion.h | ksmotion.h |
程式庫 | KsApi_Rtss.lib | KsApi.lib |
參見